﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Kinect;
enum TargetNode{
    HandRightNode,
    HandLeftNode,
    FootRightNode,
    FootLeftNode,
    HeadNode
}
enum Type
{
    HandRigh,
    HandLeft,
    FootRight,
    FootLeft,
    Head
}

namespace Kinect_Dance.Objects
{
    public class C_pCircle
    {
        public Texture2D pTexture { get; set; }
        public int scaleCircle { get; set; }
        public int timeStart { get; set; }
        public int ToadoX { get; set; }
        public int ToadoY { get; set; }
        public JointType type { get; set; }
        public int targetNode;
        
        public float timeLife { get; set; }
        public int[] ParamInt  = new int[5];
        public C_pCircle()
        {
            type = JointType.Head;
            ToadoY = ToadoY = 0;
            scaleCircle = 1;
            timeLife = 1000;
            ParamInt[0] = (int)type;
            ParamInt[1] = ToadoX;
            ParamInt[2] = ToadoY;
            ParamInt[3] = timeStart;
            ParamInt[4] = (int)TargetNode.HeadNode;
        }
        public C_pCircle(int timestart)
        {
            ToadoY = ToadoY = 0;
            scaleCircle = 1;
            timeLife = 1000;
            timeStart = timestart;
            ParamInt[0] = (int)type;
            ParamInt[1] = ToadoX;
            ParamInt[2] = ToadoY;
            ParamInt[3] = timestart;
            ParamInt[4] = (int)TargetNode.HeadNode;
        }

        public int f_TargetNode(Skeleton [] skeletondata)
        {
            int playerSkeleton=0;
            for (int i = 0; i < 5;i++ )
            {
                if (skeletondata[i].TrackingId>0)
                {
                    playerSkeleton = i;
                }
            }
            float hieusoX = (skeletondata[playerSkeleton].Joints[this.type].Position.X * 400 + 400);
            float hieusoY = (skeletondata[playerSkeleton].Joints[this.type].Position.Y * 300 + 300);
            if (hieusoX < (pTexture.Width+ToadoX) && hieusoX > (ToadoX - pTexture.Width) )
            {
                if (hieusoY < (pTexture.Height + ToadoY) && hieusoY > (ToadoY - pTexture.Height ))
                {
                    return 1;
                }
            }            
            return 0;
        }

        public void f_scaleCircle(int scale)
        {
            scaleCircle = scale;
        }

        public void f_draw(SpriteBatch cSpriteBatch)
        {
            Rectangle cRectangle = new Rectangle(ToadoX, ToadoY, pTexture.Width * scaleCircle, pTexture.Height * scaleCircle);
            //cSpriteBatch.Begin();
            cSpriteBatch.Draw(pTexture, cRectangle, Color.White);
            //cSpriteBatch.End();
        }

        public void f_detroyCircle()
        {
           
        }

    }
}
